package com.guochenglang.www.dao;

import com.guochenglang.www.pojo.Comment;

import java.sql.SQLException;
import java.util.ArrayList;

/**
 * @author GuoChenglang
 */
public interface CommentDao {
    /**
     * 搜索评论
     *
     * @param comment 评论条件
     * @return 评论列表
     * @throws SQLException           sql异常
     * @throws IllegalAccessException 非法访问异常
     * @throws InstantiationException 实现异常
     * @throws InterruptedException   断点异常
     */
    ArrayList<Comment> commentSelect(Comment comment) throws SQLException, IllegalAccessException, InstantiationException, InterruptedException;

    /**
     * 分页查询评论
     *
     * @param page    当前页码
     * @param num     每页显示个数
     * @param comment 搜素条件
     * @param order   排序条件
     * @param mode    升序还是降序
     * @return 评论列表
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     * @throws InstantiationException 实现异常
     */
    ArrayList<Comment> commentSelectByLimit(int page, int num, Comment comment, String order, String mode) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException;

    /**
     * 添加评论
     *
     * @param comment 评论信息
     * @return 添加的主键
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     */
    int insertComment(Comment comment) throws SQLException, InterruptedException, IllegalAccessException;

    /**
     * 更新评论
     *
     * @param set        更新的数据
     * @param conditions 更新的条件
     * @return 更新行数
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     */
    int updateComment(Comment set, Comment conditions) throws SQLException, InterruptedException, IllegalAccessException;

    /**
     * 删除评论
     *
     * @param conditions 删除评论的条件
     * @return 删除行数
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     */
    int deleteComment(Comment conditions) throws SQLException, InterruptedException, IllegalAccessException;
}
